<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>我的账户</title>
	<link rel="stylesheet" type="text/css" href="/static/app/css/common.css">
	<!-- <link rel="stylesheet" type="text/css" href="/static/app/css/swiper-4.2.2.min.css"> -->
	<link rel="stylesheet" type="text/css" href="/static/app/css/merchantAccount.css">
	
</head>
<body>
	<div id="container">
		<div id="head">
			<a href="javascript:;"><img class="back" src="/static/app/images/icon_back2.png"></a>
			<p class="title">我的账户</p>
			<!-- <a href="./html/unboundCard.html"><p class="cash">提现</p></a> -->
		</div>
		<div id="con">
			<h2>账户余额（元）</h2>
			<p class="money"></p>
			<div class="details">
				<ul class="tab flex">
					<li class="active" id="day" data-type="1">日</li>
					<li id="week" data-type="2">周</li>
					<li id="mouth" data-type="3">月</li>
					<li id="year" data-type="4">年</li>
				</ul>
				<ul class="sheet">
					<li>类型</li>
					<li>收入/支出</li>
					<li>当前余额</li>
					<li>创建日期</li>
				</ul>
				<div class="items" id="merchant">

				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="/static/app/js/common/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="/static/app/js/common/commonUrl.js"></script>
	<script type="text/javascript" src="/static/app/js/common/common.js"></script>
	<script src="/static/app/js/alljs/merchantAccount.js"></script>
	<script src="/static/app/js/common/template.js"></script>

	<!-- 详细信息模板 -->
	<script id="merchantTpl" type="text/html">
		<% for(var i = 0; i < data.list.length; i++) {%>
			<ul class="list">

				<% if(data.list[i].type == 0) {%>
					<li>收入</li>
					<li><%:=data.list[i].fee%></li>
					<li><%:=parseInt(data.list[i].fee)%></li>
					<li><%:=data.list[i].createtime%></li>
				<% } else if(data.list[i].type == 1) {%>
					<li>支出</li>
					<li>-<%:=data.list[i].fee%></li>
					<li><%:=parseInt(totalMoney) - parseInt(data.list[i].fee)%></li>
					<li><%:=data.list[i].createtime%></li>
				<% } else {%>
					<li>提现</li>
					<li>-<%:=data.list[i].fee%></li>
					<li><%:=parseInt(totalMoney) - parseInt(data.list[i].fee)%></li>
					<li><%:=data.list[i].createtime%></li>
				<% } %>
			</ul>
		<% } %>
	</script>

	<script>
		var loginUserId = getCookie('loginUserId');
		totalMoney = getUrlParam('totalMoney');
		var shopIds = getUrlParam('id');
		$('.money').html(totalMoney);
		$('.back').click(function(){
			window.history.go(-1);
		})
		var merchantTpl = document.getElementById('merchantTpl').innerHTML;
 	var merchantList = $('#merchant');
		const distanceMerchant = global + '/v1.0/merchant/amountDetail';
		$('.details .tab li').click(function() {
			data_type = $(this).attr('data-type');
  	merchant(merchantTpl, merchantList, shopIds, data_type, 1, 10);
 	});
		function merchant(Tpl, list, shopId, queryType, pageNum, pageSize) {
			$.ajax({
					url: distanceMerchant,
					type: 'get',
					dateType: 'json',
					data: {
						shopId: shopId, 
						queryType: queryType,
						pageNum: pageNum,
						pageSize: pageSize
					},
					success: function(msg) {  
						if(msg.code == 200) {
							var html = template(Tpl, msg);
							list.html(html);
						}
					}
				})
		};
		merchant(merchantTpl, merchantList, shopIds, 1, 1, 10);
		
	</script>
</body>
</html>